package com.suanfa.collect;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jukg
 * @date 2025/01/10 15:04
 * @description 员工作弊，分差最小的员工
 */
public class StaffCheat {

    public static void main(String[] args) {
        List<int[]> staff = new ArrayList<>();
        staff.add(new int[]{1,90});
        staff.add(new int[]{2,91});
        staff.add(new int[]{3,92});
        staff.add(new int[]{4,85});
        staff.add(new int[]{5,86});
        staff = getCheatStaff(staff);
        System.out.println(staff);
    }



    public static List<int[]> getCheatStaff(List<int[]> staff){

        int min = Integer.MAX_VALUE;
        if(staff.size() < 2){
            return staff;
        }

        List<int[]> cheatStaff = new ArrayList<>();

        for(int i=1; i< staff.size(); i++){
            int min2 = Math.abs(staff.get(i)[1] - staff.get(i-1)[1]);
            if(min > min2){
                min = min2;
                cheatStaff.clear();
                cheatStaff.add(new int[]{staff.get(i - 1)[0], staff.get(i)[0]});
            }else if(min == min2){
                cheatStaff.add(new int[]{staff.get(i - 1)[0], staff.get(i)[0]});
            }

        }
        return cheatStaff;
    }
}
